Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@universal-packages/directory-traversal
Advanced tools
Simple tool to traverse a directory deeply and get desired info
Sometimes you just need a way to map a directory to either load modules in real time or just get the available files to run a task, directory traversal will map a directory for you and deliver a convenient DirectoryMap
object for you.
npm install @universal-packages/directory-traversal
traverse(locations: String, [options])
The traverse function will go recursively from a root directory until it maps the whole tree, you can execute a callback for every visited directory after being mapped, limit the depth and filter for files you want or you not want to be mapped, returning a DirectoryMap
object
import { traverse } from '@universal-packages/directory-traversal'
const directoryMap = traverse('~/projects')
console.log(directoryMap)
You can modify the behavior of the traverse function by providing options.
callback
Function
A function to call for every mapped directory for you to analyze in place, return false if you want to stop going deeper into that directory.
const directoryMap = traverse('~/projects', {
callback: (directoryMap) => {
if (directoryMap.path.include('homework')) {
return false
}
}
})
fileFilter
(yml | yaml | js | json)[] | Regex
To only include files that satisfies this condition.
maxDepth
Number
To only map files going this level deep.
From the traverse example you will get something like this:
{
"path": "home/projects",
"files": [],
"directories": [
{
"path": "home/projects/universal-directory-traversal",
"files": [
"home/projects/universal-directory-traversal/.editorconfig",
"home/projects/universal-directory-traversal/.gitignore",
"home/projects/universal-directory-traversal/CODE-OF-CONDUCT.md",
"home/projects/universal-directory-traversal/CONTRIBUTING.md",
"home/projects/universal-directory-traversal/LICENSE.md",
"home/projects/universal-directory-traversal/README.md",
"home/projects/universal-directory-traversal/package-lock.json",
"home/projects/universal-directory-traversal/package.json",
"home/projects/universal-directory-traversal/tsconfig.dis.json",
"home/projects/universal-directory-traversal/tsconfig.json"
],
"directories": []
}
]
}
This library is developed in TypeScript and shipped fully typed.
The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.
FAQs
Simple tool to traverse a directory deeply and get desired info
The npm package @universal-packages/directory-traversal receives a total of 16,113 weekly downloads. As such, @universal-packages/directory-traversal popularity was classified as popular.
We found that @universal-packages/directory-traversal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.